package thinkingInJava.String_.regex_;

//: strings/SplitDemo.java
import java.util.regex.*;
import java.util.*;
import static thinkingInJava.YTool.YPrint.*;

public class PatternSplit {
public static void main(String[] args) {
  String input =
    "This!!unusual use!!of exclamation!!points";
  println(Arrays.toString(
    Pattern.compile("!!").split(input)));
  // Only do the first three:
  println(Arrays.toString(
    Pattern.compile("!!").split(input, 3)));
  
  input = "This!!unusual use!!of exclamation!!points";
	println(Arrays.toString(input.split("!!")));	// 可以看出 String.split 与 Pattern.split 是一模一样的
	// Only do the first three:
	println(Arrays.toString(input.split("!!", 3)));
}
} /* Output:
[This, unusual use, of exclamation, points]
[This, unusual use, of exclamation!!points]
[This, unusual use, of exclamation, points]
[This, unusual use, of exclamation!!points]
*///:~

